<template name="paybox">
	<u-popup v-model="show" :class="lang" class="popup" mode="bottom" border-radius="100"
		:custom-style="{backgroundColor: 'rgba(0, 0, 0, 0)'}" @close="closepop" length="1197" :closeable="closeable">
		<view class="paybox-box">
			<view class="paybox-bg">
				<image class="paybox-bg-img"
					src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/paybobg.png"></image>
			</view>
			<view class="paybox-content">
				<view class="paybox-class">
					<view class="paybox-class-item" :class="vipcart == true ? 'selected' : ''" @click="cartclick(1)">
						<view class="paybox-class-item-title">
							{{ $t('ucenters.超级会员') }}
						</view>
						<view v-if="lang == 'cn'" class="paybox-class-item-money" :class="lang+'layout'">
							<text :class="vipcart == true ? 'colored' : ''">{{ $t('ucenters.超级金额') }}</text>
							<text :class="vipcart == true ? 'colored' : ''" class="year">{{ $t('ucenters.年') }}</text>
						</view>
						<view v-else class="paybox-class-item-money" :class="lang+'layout'" style="direction:rtl;">
							<text :class="vipcart == true ? 'colored' : ''" class="year">{{ $t('ucenters.年') }}</text>
							<text :class="vipcart == true ? 'colored' : ''"
								style="direction:ltr;">{{ $t('ucenters.超级金额a') }}</text>
						</view>
						<view class="paybox-class-item-time">
							{{ $t('ucenters.没有时间限制') }}
						</view>
						<view class="tuijian">{{ $t('ucenters.推荐') }}</text></view>
					</view>
					<view class="paybox-class-item" :class="seasoncart == true ? 'selected' : ''" @click="cartclick(0)">
						<view class="paybox-class-item-title">
							{{ $t('ucenters.普通会员') }}
						</view>
						<view v-if="lang == 'cn'" class="paybox-class-item-money" :class="lang+'layout'">
							<text :class="seasoncart == true ? 'colored' : ''">{{ $t('ucenters.普通金额') }}</text>
							<text :class="seasoncart == true ? 'colored' : ''"
								class="year">{{ $t('ucenters.半年') }}</text>
						</view>

						<view v-else class="paybox-class-item-money" :class="lang+'layout'">
							<text :class="seasoncart == true ? 'colored' : ''"
								class="year">{{ $t('ucenters.半年') }}</text>
							<text :class="seasoncart == true ? 'colored' : ''"
								style="direction:ltr;">{{ $t('ucenters.普通金额a') }}</text>
						</view>


						<view class="paybox-class-item-time">
							{{ $t('ucenters.使用期半年') }}
						</view>
					</view>
				</view>

				<view class="payfor-zl">
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/yuyan.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.多种语言') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/tiku.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.最新题库') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/jiqiao.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.答题技巧') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/kcmn.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.考场模拟') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/spjj.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.视频讲解') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/dgmn.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.灯光模拟') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/jxwb.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.精选500题') }}
						</view>
					</view>
					<view class="payfor-zl-item">
						<image class="payfor-zl-img"
							src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/spjq.png">
						</image>
						<view class="payfor-zl-item-text">
							{{ $t('ucenters.视频技巧') }}
						</view>
					</view>
				</view>

				<!-- 支付方式 -->

				<view v-if="loginshenhe && isShow == false" class="payforSub" @click="pay">
					{{ $t('ucenters.立即购买') }}￥{{vipcart==true ?'50':'30'}}
				</view>

				<view v-else class="">
					<!-- <view class=""> -->
					<view class="payfor-type">
						<view class="payfor-text">
							{{$t('shopcarts.支付方式')}}
						</view>
						<view class="payfor-class">
							<view class="payfor-class-item" :class="{payfored:paytypetext=='wxpay'}"
								style="width: 340rpx;" @click="radioChange('wxpay')">
								<image class="payfor-img"
									src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/wx.png">
								</image>
								<view class="payfor-class-text">
									{{$t('usercenter.微信支付')}}
								</view>
							</view>
							<!-- #ifdef APP-PLUS -->
							<view class="payfor-class-item" :class="{payfored:paytypetext=='alipay'}"
								style="width: 340rpx;" @click="radioChange('alipay')">
								<image class="payfor-img"
									src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/zfb.png">
								</image>
								<view class="payfor-class-text">
									{{$t('usercenter.支付宝支付')}}
								</view>
							</view>
							<!-- #endif -->

						</view>
					</view>
					<!-- 支付 -->
					<view class="payforSub" @click="orderpay">
						{{ $t('ucenters.立即购买') }}￥{{vipcart==true ?'50':'30'}}
					</view>
				</view>



			</view>

		</view>

	</u-popup>
</template>

<script>
	//接口
	import {
		siteurl,
		wxlogin_api,
		pay_api,
		checkpay_api,
		applepay_api,
		isShow_api
	} from '@/api/index';
	export default {
		name: 'paybox',
		props: {
			show: {
				type: Boolean,
				default () {
					return false
				}
			}

		},
		data() {
			return {
				lang: this.$i18n.locale,
				seasoncart: false,
				vipcart: true,
				paytypebutton: false,
				buttontext: this.$t('ucenters.选择卡类型'),
				paytypetext: 'wxpay',
				paytypetotal: true, //支付类型未选择
				carttypetotal: true, //卡类型未选择
				closeable: false,
				closeIconPos: 'top-right',
				carttitlecon: this.$t('usercenter.普通卡介绍'),
				cartcontent: this.$t('usercenter.普通卡介绍内容'),
				paymoney: '30',
				terminalname: 'app',
				loginshenhe: "",
				product_list: [{
						productid: '10018',
						checked: true,
						title: '普通会员',
						digest: '(有效期半年)',
						info: '普通会员尊享：提供汉语、维吾尔语、哈萨克语等语言的驾驶证考试和资格证考试教学内容；C1C2C3、A1A3、A2B2、DEF的科目一、科目二、科目三、科目四和资格证考试内容；科目一、科目四题目解释、模拟考试、听题功能；科目二、科目三和灯光视频教程，快速掌握考点；会员有效期6个月，会员是虚拟商品，不支持退款！',
						price: 30
					},
					{
						productid: 'cjhy10030',
						checked: true,
						title: '超级会员',
						digest: '(有效期一年)',
						info: '超级会员尊享：提供汉语、维吾尔语、哈萨克语等语言的驾驶证考试和资格证考试教学内容；C1C2C3、A1A3、A2B2、DEF的科目一、科目二、科目三、科目四和资格证考试内容；科目一、科目四题目解释、模拟考试、听题功能；科目二、科目三和灯光视频教程，快速掌握考点；会员有效期1年，会员是虚拟商品，不支持退款！',
						price: 50,
					},

				], // 应用内购项目列表
				iap: null,
				ids: ['10018', 'cjhy10030'],
				isShow: null,
			};
		},
		watch: {
			show(val) {
				this.show = val // 新增isVisible的watch，监听变更并同步到IsShowPage上
			}
		},

		created() {
			var that = this;
			console.log("会员弹框")
			uni.getSystemInfo({
				success: function(res) {
					console.log("res", res)
					if (res.platform == 'ios') {
						console.log('苹果机器');
						that.loginshenhe = true;
						that.getChannels()
					} else {
						console.log('不是苹果机器222');
						stystems = 'android';
						that.loginshenhe = false;
					}
					console.log(res.platform);
				}
			});
			that.handleShow()

		},
		onShow() {




			var that = this;
			// console.log("terminal name////////////////////////////////")
			// #ifdef MP-WEIXIN
			that.terminalname = 'miniprog';
			that.paytypetotal = true;
			that.carttypetotal = true;
			that.paytypetext = 'wxpay';
			// #endif

			// #ifdef APP-PLUS
			that.terminalname = 'app';
			// #endif

			// uni.getSystemInfo({
			// 	success: function(res) {
			// 		if (res.platform == 'ios') {
			// 			console.log('苹果机器');
			// 			that.loginshenhe = true;
			// 		} else {
			// 			console.log('不是苹果机器222');
			// 			stystems = 'android';
			// 			that.loginshenhe = false;
			// 		}
			// 		console.log(res.platform);
			// 	}
			// });
		},
		methods: {
			handleShow() {
				this.http({
					url: isShow_api,
					method: 'GET',
					header: {
						'content-type': 'application/json'
					},
					data: {},
					success: res => {
						console.log("模块显隐", res)
						this.isShow = res.isShow
					},
					fail: err => {
						console.log(err);
					}

				});
			},
			getChannels() {
				// #ifdef APP-PLUS
				var that = this;

				plus.payment.getChannels(
					res => {

						let channel = res.find(i => i.id === 'appleiap');
						that.iap = channel ? channel : null;
						that.requestOrder();
					},
					function(e) {
						console.log("获取支付通道失败，请稍后重试。")
						plus.nativeUI.alert("获取支付通道失败，请稍后重试。", function() {}, "提示");
					}
				);
				// #endif
			},
			requestOrder() {
				// #ifdef APP-PLUS
				if (this.iap) {
					this.iap.requestOrder(
						this.ids,
						res => {
							console.log("内购商品列表   " + JSON.stringify(res))
							this.product_list.forEach((prod, index) => {
								res.forEach((item, i) => {
									if (prod.productid === item.productid) {
										prod.pricelocal = item.pricelocal
									}
								})
							})

							// this.product_list = res;
						},
						function(errormsg) {
							plus.nativeUI.alert('获取应用内购项目失败，请稍后重试。', function() {}, '提示');
						}
					);
				} else {
					console.log("获取支付渠道失败");
					plus.nativeUI.alert('获取支付渠道失败，请稍后重试。', function() {}, '提示');
				}

				// #endif
			},
			// 调起支付
			pay() {
				let productid = ""
				if (this.vipcart) {
					productid = this.product_list[1].productid
				} else {
					productid = this.product_list[0].productid
				}
				console.log(productid, "productid")
				var that = this;
				console.log("支付开始了")
				// #ifdef APP-PLUS
				uni.showLoading({
					title: '支付中请勿离开',
					mask: true
				})

				uni.requestPayment({
					provider: 'appleiap',

					orderInfo: {
						productid: productid
					},

					success: e => {
						//e：返回的参数
						uni.hideLoading();
						console.log(e)
						that.payinfos();

						//1.未了防止掉单，建议先订单数据保存到本地

						//2.请求客户服务器的业务接口，成功后删除，该本地数据


					},

					fail: e => {
						uni.hideLoading();
						console.log("zhifu shi bai", e)
						console.log(e)
						uni.showModal({
							content: '充值失败,请重试',

							showCancel: false
						});
					},

					complete: () => {
						uni.hideLoading();
					}
				});

				// #endif
			},
			payinfos() {
				var that = this;

				try {
					const useridd = uni.getStorageSync('user_infos');

					var openidinfo = useridd.openid;
					console.log('ipendi', openidinfo);

					//调用临时接口
					that.https({
						url: applepay_api,
						method: 'POST',
						data: {
							type: 1,
							openId: openidinfo
						},
						success: resy => {
							console.log('后台返回信息', resy);
							//that.cartshoptxt = resy;
							if (resy.result_code == 0) {
								console.log('开通成功了');
							} else {
								console.log('开通失败了');
							}
							uni.reLaunch({
								url: '../index/start'
							});
						},
						fail: err => {
							console.log(err);
						},
						complete: function(eeee) {
							//console.log(eeee,'com')
						}
					});
					console.log(useridd);
				} catch (e) {
					// error
				}
			},
			// =====================================================================================================

			radioChange: function(evt) {
				console.log('evt');
				console.log(evt);
				var that = this;
				that.paytypebutton = true;
				that.paytypetotal = true;
				that.paytypetotal = true;
				that.paytypetext = evt;
				that.paytext();
				//that.orderpay(evt);
				// for (let i = 0; i < this.items.length; i++) {
				//     if (this.items[i].value === evt.detail.value) {
				//         this.current = i;
				//         break;
				//     }
				// }
			},
			closepop() {
				var that = this;
				that.show = false;
				var ceshitime = uni.getStorageSync('tiyan_times');
				//控制没会员操作
				// that.$emit('handleok');
				uni.getStorage({
					key: 'exam_type',
					success: function(res) {
						console.log('已经设置过了，不要重复设置，如果想重复设置，请清理kem——type');
						if (res.data == "zigezheng") {
							if (ceshitime > 0) {
								that.show = false;
							} else {
								uni.navigateTo({
									// url: '../index/qualification'
								});
							}

						} else {
							if (ceshitime > 0) {
								that.show = false;
							} else {
								uni.navigateTo({
									// url: '../index/index'
								});
							}

						}
					},
					fail(e) {
						console.log('没有设置科目，请继续设置');
						uni.navigateTo({
							url: '../setting/setting'
						});
					}
				});


			},
			cartclick(num) {
				var that = this;

				console.log("eeeeeeeeeeeeeee", this.paytypetext)


				if (num == 0) {
					that.seasoncart = true;
					that.vipcart = false;
					//that.paymoney = '30';
					that.carttitlecon = that.$t('usercenter.普通卡介绍');
					that.cartcontent = that.$t('usercenter.普通卡介绍内容');
				}
				if (num == 1) {
					that.seasoncart = false;
					that.vipcart = true;
					//that.paymoney = '50';
					that.carttitlecon = that.$t('usercenter.超级卡介绍');
					that.cartcontent = that.$t('usercenter.超级卡介绍内容');
				}

				that.carttypetotal = true;

				// #ifdef MP-WEIXIN
				that.terminalname = 'miniprog';
				that.paytypetotal = true;
				that.carttypetotal = true;
				that.paytypetext = 'wxpay';
				// #endif


				that.https({
					url: 'money.html',
					method: "POST",
					data: {
						//type:type
					},
					success: res => {
						//console.log(res);
						var resdata = res.split("#");
						console.log("num", num, resdata[0], resdata[1])
						if (num === 0) {
							that.paymoney = resdata[0];
						}
						if (num === 1) {
							that.paymoney = resdata[1];
						}
						that.paytext();

						//console.log(resdata[0],resdata[1]);
					},
					fail: err => {
						console.log(err);
					},
					complete: function(eeee) {
						//console.log(eeee,'com')
					}
				});


			},
			paytext() {
				var that = this;


				console.log('paytext=', that.paytypetext);
				if (that.paytypetotal == false) {
					that.buttontext = this.$t('ucenters.选择支付方式');
					return false;
				} else if (that.carttypetotal == false) {
					that.buttontext = this.$t('ucenters.选择卡类型');
					return false;
				} else {
					if (this.lang == 'cn') {
						that.buttontext = this.$t('ucenters.支付') + '  ' + that.paymoney + ' ' + this.$t('usercenter.元');
					} else {
						that.buttontext = that.paymoney + ' ' + this.$t('usercenter.元') + '  ' + this.$t('ucenters.支付');
					}
				}

				// if (that.paytypetext !== 'null' || (that.seasoncart == true && that.vipcart == true)) {
				// 	that.buttontext = this.$t('ucenters.支付');
				// } else if (that.paytypetext == 'null') {
				// 	that.buttontext = this.$t('ucenters.选择支付方式');
				// } else {
				// 	that.buttontext = this.$t('ucenters.选择卡类型');
				// }
			},

			orderpay(evt) {
				var that = this;
				console.log('pay start')
				var ptext = that.paytypetext;

				if (that.carttypetotal == false) {
					that.buttontext = this.$t('ucenters.选择卡类型');
					uni.showModal({
						title: that.$t('jihuo.提示'),
						content: this.$t('ucenters.选择卡类型'),
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return false;
				}

				if (that.paytypetotal == false) {
					uni.showModal({
						title: that.$t('jihuo.提示'),
						content: this.$t('ucenters.选择支付方式'),
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					that.buttontext = this.$t('ucenters.选择支付方式');
					return false;
				}


				console.log('zhifu ---- kkkkkk', ptext);
				uni.showLoading({
					title: '加载中'
				});
				uni.getStorage({
					key: 'user_infos',
					success: function(res) {
						console.log("res000000", res);
						var paytype_wxpay = 'wxpay';
						var pay_lx = 'weixin';
						if (ptext == 'wxpay') {
							console.log('微信支付');
							paytype_wxpay = 'wxpay';
							pay_lx = 'weixin';
						}
						if (ptext == 'alipay') {
							console.log('支付宝支付');
							paytype_wxpay = 'alipay';
							pay_lx = 'zhifubao';
						}
						var uinfo = res.data;

						var stystems = null;
						// #ifdef APP-PLUS
						uni.getSystemInfo({
							success: function(res) {
								if (res.platform == 'ios') {
									console.log('苹果机器');
									stystems = 'iphone';
								} else {
									console.log('不是苹果机器222');
									stystems = 'android';
								}
								console.log(res.platform);
							}
						});
						// #endif

						// #ifdef MP-WEIXIN
						stystems = 'miniprog';
						// #endif
						uni.showLoading({
							title: '加载中'
						});

						var userttype = 0;
						if (that.seasoncart == true) {
							userttype = 0;
						} else {
							userttype = 1;
						}

						let data = {
							unionid: uinfo.unionid,
							openid: uinfo.openid,
							system: stystems,
							zflx: pay_lx, //支付类型:weixin,zhifubao
							shplx: userttype, //0,1,2 例如用户开通会员，或者会员购买了卡号卡密等
							shpid: 0 // 商品id
						}
						// console.log(11111111);
						// console.log(data);
						console.log(siteurl + '/Service/pay.do');

						uni.request({
							url: siteurl + '/Service/pay.do', //仅为示例，并非真实接口地址。
							// url: "http://10.0.0.125:9099" + '/Service/pay.do', //仅为示例，并非真实接口地址。
							data: {
								unionid: uinfo.unionid,
								openid: uinfo.openid,
								system: stystems,
								zflx: pay_lx, //支付类型:weixin,zhifubao
								shplx: userttype, //0,1,2 例如用户开通会员，或者会员购买了卡号卡密等  218521
								shpid: 0 // 商品id
							},
							method: 'POST',
							header: {
								'Content-Type': 'application/json'
							},
							success: res => {
								// console.log("res0000000000000000000000", JSON.stringify(res));
								console.log("res0000000000000000000000", res.data.ddh, res.data);
								var order_info;
								var order_miniinfo;
								var ddhnum = res.data.ddh;
								if (res.data.result_code == -2) {
									uni.showModal({
										title: '订单创建失败',
										content: res.data.result_msg,
										success: function(res) {
											if (res.confirm) {
												console.log('用户点击确定');
												uni.hideLoading();
											} else if (res.cancel) {
												console.log('用户点击取消');
												uni.hideLoading();
											}
										}
									});
									return false;
								}
								if (paytype_wxpay == 'wxpay') {
									order_miniinfo = res.data.wxbjson
									order_info = JSON.stringify(res.data.wxbjson);
								}
								if (paytype_wxpay == 'alipay') {
									order_info = res.data.zfbpaystr
								}
								let orderInfo = JSON.stringify(res.data);
								console.log(order_info);
								//#ifdef APP-PLUS
								console.log(paytype_wxpay);
								console.log(order_info);
								uni.requestPayment({
									provider: paytype_wxpay,
									orderInfo: order_info, //微信、支付宝订单数据
									success: function(res) {
										console.log('支付成功！');

										uni.showLoading({
											title: '加载中'
										});

										console.log('success:' + JSON.stringify(res));
										//支付成功
										//更新会员状态
										var versionsss = plus.runtime.version;

										setTimeout(function() {
											that.paystatus(uinfo, stystems,
												versionsss, ddhnum);
										}, 500)
									},
									fail: function(err) {
										console.log('fail:' + JSON.stringify(err));

										uni.hideLoading();
										//fail:{"errMsg":"requestPayment:fail"}
										// that.orders(0);
										//alert(JSON.stringify(err));
									},
									complete: function(e) {
										// this.orders(ordernum,2);
										// that.sendmsg();

									}
								});
								// #endif
							},
							complete: function(e) {
								console.log(e);
								// uni.showModal({
								// 	title: that.$t('jihuo.提示'),
								// 	content: e.data.result_msg,
								// 	success: function(res) {
								// 		if (res.confirm) {
								// 			console.log('用户点击确定');
								// 		} else if (res.cancel) {
								// 			console.log('用户点击取消');
								// 		}
								// 	}
								// });
							},
							fail: function(e) {
								uni.hideLoading();
								if (pay_lx == 'zhifubao') {
									uni.showModal({
										title: that.$t('jihuo.提示'),
										content: e.data,
										success: function(res) {
											if (res.confirm) {
												console.log('用户点击确定');
											} else if (res.cancel) {
												console.log('用户点击取消');
											}
										}
									});
								} else {
									uni.showModal({
										title: that.$t('jihuo.提示'),
										content: e.data.result_msg,
										success: function(res) {
											//that.wxloginshow = true;
											if (res.confirm) {
												console.log('用户点击确定');
											} else if (res.cancel) {
												console.log('用户点击取消');
											}
										}
									});

								}
							}

						});
					},
					fail() {
						//返回登录按钮，重新微信登录
						uni.hideLoading();
					}
				});
			},
			paystatus: function(uinfo, stystems, versionsss, ddhnum) {
				var that = this;
				that.http({
					url: checkpay_api,
					method: 'POST',
					header: {
						// 'content-type': 'application/x-www-form-urlencoded'
						'content-type': 'application/json'
					},
					data: {
						ddh: ddhnum
					},
					success: resu => {
						console.log("resu=", resu);
						console.log(JSON.stringify(resu));
						if (resu.result_code == 1) {
							setTimeout(function() {
								that.paystatus(uinfo, stystems, versionsss, ddhnum);
							}, 5000)
						} else if (resu.result_code == 0) {
							uni.showLoading({
								title: '加载中'
							});
							that.userstatus(uinfo, stystems, versionsss);
						} else {
							uni.hideLoading();
							uni.showModal({
								title: '错误提示',
								content: '订单支付失败或无查询到订单号',
								success: function(res) {
									//that.wxloginshow = true;
									if (res.confirm) {
										that.tiaozhuan();
										console.log('用户点击确定');
									} else if (res.cancel) {
										that.tiaozhuan();
										console.log('用户点击取消');
									}
								}
							});
						}
					},
					fail: err => {
						uni.hideLoading();
						uni.showModal({
							title: '服务错误提示',
							content: '订单支付状态查询失败',
							success: function(res) {
								//that.wxloginshow = true;
								if (res.confirm) {
									that.tiaozhuan();
									console.log('用户点击确定');
								} else if (res.cancel) {
									that.tiaozhuan();
									console.log('用户点击取消');
								}
							}
						});
						console.log(err);
					}

				});

			},
			userstatus: function(uinfo, stystems, versionsss) {
				var that = this;
				console.log("更新会员状态")

				// #ifdef MP-WEIXIN
				var devid = '100010010';
				var system_info = 'miniprogram'
				// #endif
				// #ifdef APP-PLUS
				var devid = plus.device.uuid;
				var system_info = plus.device.model
				// #endif

				that.http({
					url: wxlogin_api,
					method: 'POST',
					header: {
						// 'content-type': 'application/x-www-form-urlencoded'
						'content-type': 'application/json'
					},
					data: {
						openid: uinfo.openid,
						unionid: uinfo.unionid,
						nick_name: uinfo.nick_name,
						pic_url: uinfo.pic_url,
						sex: uinfo.gender,
						gexing: null,
						devid: devid,
						system: stystems,
						system_info: system_info,
						version: versionsss,
						lastuptime: 0,
						lang: that.lang,
						apple_openid: null,
						apple_name: null,
						apple_famila: null,
						apple_email: null
					},
					success: resu => {
						console.log(resu);
						console.log(JSON.stringify(resu));
						//存储openid
						uni.setStorageSync('openid', uinfo.openid);
						var obj = JSON.parse(
							'{"openid":"' +
							uinfo.openid +
							'","unionid": "' +
							uinfo.unionid +
							'","kaishiriqi":"' +
							resu.kaishiriqi +
							'","jieshuriqi":"' +
							resu.jieshuriqi +
							'","userstatus":"' +
							resu.userstatus +
							'","jihuofangshi":"' +
							resu.jihuofangshi +
							'","nick_name":"' +
							uinfo.nick_name +
							'","pic_url":"' +
							uinfo.pic_url +
							'","uid":"' +
							resu.uid +
							'","dailijibie":"' +
							resu.dailijibie +
							'"}'
						);
						uni.setStorageSync('user_infos', obj);
						uni.hideLoading();
						//支付成功后状态修改，如果状态修改了 那就跳转到首页
						uni.showModal({
							title: that.$t('jihuo.提示'),
							content: that.$t('jihuo.激活成功'),
							success: function(res) {
								//that.wxloginshow = true;
								if (res.confirm) {
									that.tiaozhuan();

									console.log('用户点击确定');
								} else if (res.cancel) {
									that.tiaozhuan();
									console.log('用户点击取消');
								}
							}
						});

						//that.wxloginshow = false;
						//判断是否激活过 如果激活过，跳转到首页，如果没没有激活，继续激活
						// userstatus -- -3其他情况 -2到期 -1禁用 0-不是会员 1-普通会员 2-高级会员 3代理
						//var userstatus = res.userstatus;
						//var userstatus = -2;




					},
					fail: err => {
						console.log(err);
						uni.hideLoading();
						uni.showModal({
							title: '服务错误提示',
							content: '会员状态查询失败',
							success: function(res) {
								//that.wxloginshow = true;
								if (res.confirm) {
									that.tiaozhuan();
									console.log('用户点击确定');
								} else if (res.cancel) {
									that.tiaozhuan();
									console.log('用户点击取消');
								}
							}
						});
					}

				});
			},
			tiaozhuan: function() {
				var that = this;
				uni.getStorage({
					key: 'exam_type',
					success: function(res) {
						console.log('已经设置过了，不要重复设置，如果想重复设置，请清理kem——type');
						if (res.data == "zigezheng") {
							uni.reLaunch({
								url: '../index/start'
							});
						} else {
							uni.reLaunch({
								url: '../index/start'
							});
						}
					},
					fail(e) {
						console.log('没有设置科目，请继续设置');
						uni.reLaunch({
							url: '../index/start'
						});
					}
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	::v-deep .u-drawer-content {
		background-color: transparent !important;
		// margin-left: 100rpx;
	}

	.long-popup {
		transform: none;
	}

	.paybox-box {
		position: relative;

		.paybox-bg {
			.paybox-bg-img {
				width: 750rpx;
				height: 1197rpx;
			}
		}

		.paybox-content {
			width: 100%;
			height: 970rpx;
			z-index: 999;
			position: absolute;
			bottom: 0;

			.paybox-class {
				width: 630rpx;
				height: 193rpx;
				margin: 0 auto;
				display: flex;
				justify-content: space-between;

				.paybox-class-item {
					width: 299rpx;
					height: 193rpx;
					border-radius: 20rpx;
					border: 1px solid #FFDEAC;
					padding: 27rpx 27rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					position: relative;
					align-items: center;


					.paybox-class-item-title {
						font-size: 28rpx;
						// font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #333333;
						line-height: 33rpx;
						letter-spacing: 1px;
					}

					.paybox-class-item-money {
						font-size: 32rpx;
						// font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 38rpx;
						letter-spacing: 1px;

						.year {
							font-size: 28rpx;
						}
					}

					.paybox-class-item-time {
						width: 158rpx;
						height: 40rpx;
						background: #F6BD56;
						border-radius: 20rpx 0rpx 20rpx 0rpx;
						opacity: 1;
						font-size: 24rpx;
						// font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
						text-align: center;
						line-height: 40rpx;
					}

					.tuijian {
						min-width: 73rpx;
						// height: 33rpx;
						background: #FF4D4F;
						border-radius: 19rpx 19rpx 19rpx 0rpx;
						opacity: 1;
						font-size: 26rpx;
						// font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
						line-height: 30rpx;
						text-align: center;
						line-height: 33rpx;
						position: absolute;
						top: -25rpx;
						right: 0rpx;
						padding: 5rpx;
					}

				}

				.selected {
					background-image: url('https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/typebg.png');
					background-size: 100% 100%;
					border: none;
				}

				.colored {
					color: #B82726;
				}
			}



			.payfor-zl {
				width: 630rpx;
				height: 310rpx;
				margin: 40rpx auto;
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;

				.payfor-zl-item {
					width: 150rpx;
					// height: 120rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					// justify-content: space-between;

					// margin-right: 28rpx;
					.payfor-zl-img {
						width: 80rpx;
						height: 80rpx;
					}

					.payfor-zl-item-text {
						width: 180rpx;
						font-size: 24rpx;
						// font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #666666;
						line-height: 28rpx;
						margin-top: 15rpx;
						// white-space: nowrap;
						// overflow: hidden;
						// text-overflow: ellipsis;
						text-align: center;
					}
				}
			}


			.payfor-type {
				width: 660rpx;
				margin: 20rpx auto;

				.payfor-text {
					width: 120rpx;
					height: 42rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 35rpx;
				}

				.payfor-class {
					margin-top: 30rpx;
					width: 100%;
					display: flex;
					justify-content: space-between;

					.payfor-class-item {
						width: 308rpx;
						height: 73rpx;
						background-color: #F6F6F6;
						border-radius: 56rpx 56rpx 56rpx 56rpx;
						display: flex;
						align-items: center;

						.payfor-img {
							width: 48rpx;
							height: 48rpx;
							margin: 0 20rpx;
						}

						.payfor-class-text {
							font-size: 27rpx;
							// font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #2B2B2B;
							line-height: 73rpx;
						}
					}

					.payfored {
						background-image: url('https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/zfbg.png');
						background-size: 100% 100%;
					}


				}
			}

			.payforSub {
				margin: 0 auto;
				margin-top: 50rpx;
				width: 690rpx;
				height: 88rpx;
				background: linear-gradient(90deg, #FFDEAC 0%, #F5C781 100%);
				border-radius: 40rpx 40rpx 40rpx 40rpx;
				opacity: 1;
				font-size: 32rpx;
				// font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #9A5838;
				line-height: 88rpx;
				text-align: center;
			}

		}

	}
</style>